<?php

	/**
	 * 	
	 *
	 */
	class TimeUtil{
		
		public static  function startOfMonth(){
			return strtotime(date('Y').'-'.date('m').'-1');
		}
		
		public static function endOfMonth(){
			return mktime(0, 0, 0, date("m")+1, 0, date("Y"));
		}
		
		public static function startOfWeek(){
			$year =  date('Y');
			$month = date('m');
			$day = date('w');
			$firstDay = date('d')-$day;
			if(substr($firstDay, 0, 1) == '-'){
				$firstMonth = $month-1;
				$lastMonthDay = date('t', $firstMonth);
				$firstDay = $lastMonthDay - substr($firstDay,1);
				$time = strtotime($year . '-' . $firstMonth . '-' . $firstDay);
			}else{
				$time = strtotime($year . '-' . $month . '-' . $firstDay);
			}
			return $time;
		}
		
		public static function startOfDay(){
			return strtotime(date('Y-m-d'));
		}
		
		public static function tenDaysAfter($ts){
			$day = date('Y-m-d', $ts+86400*10);
			$date = $day . ' 23:59:59';
			return strtotime($date);			
		}
		public static function fiveDaysAfter($ts){
			$day = date('Y-m-d', $ts+86400*5);
			$date = $day . ' 23:59:59';
			return strtotime($date);			
		}
		
		public static function endOfDay($ts){
			$day = date('Y-m-d', $ts);
			$date = $day . ' 23:59:59';
			return strtotime($date);
		}
		
		/**
		 * 
		 * @param int $ts
		 * @param int $tsCompared
		 */
		public static function checkIsTheSameDay($ts, $tsCompared){
			return  self::startOfDay($ts)<=$tsCompared && self::endOfDay($ts)>=$tsCompared; 
		}
		
	}